﻿using System.Collections.Generic;
using Ext.Net;

namespace KamLib
{
    public static class ExtUilNotifications
    {

        public static void Show(this UilNotification ntf)
        {
            var n = new NotificationConfig
            {
                Title = ntf.Title,
                Html = ntf.Message,
                AutoScroll = true,
            };

            if (ntf.Pinned != null)
            {
                n.Pinned = ntf.Pinned.Value;
                if (ntf.Pinned == true)
                    n.ShowPin = true;
            }
            if (ntf.Width != null) n.Width = ntf.Width.Value;
            if (ntf.Height != null) n.Height = ntf.Height.Value;

            switch (ntf.Kind)
            {
                case UilNotificationKind.Error: n.Icon = Icon.Error; break;
                case UilNotificationKind.Info: n.Icon = Icon.Information; break;
            }

            Notification.Show(n);
        }


        public static void Show(this IEnumerable<UilNotification> notifications)
        {
            foreach (var ntf in notifications)
            {
                Show(ntf);
            }
        }
    }
}
